package me.leiusual.sharing.ui.shop.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.extensions.LayoutContainer
import kotlinx.android.synthetic.main.view_holder_shop_business_level.*
import me.leiusual.sharing.api.model.BusinessLevel
import me.leiusual.sharing.util.extension.setImageUrl

/**
 * author: leiusual
 * create on: 2019-07-30
 * description:
 */
class ShopBusinessLevelViewHolder(
    override val containerView: View,
    private val clickListener: (BusinessLevel) -> Unit
) : RecyclerView.ViewHolder(containerView), LayoutContainer, View.OnClickListener {

  private lateinit var businessLevel: BusinessLevel

  init {
    containerView.setOnClickListener(this)
  }

  fun bind(businessLevel: BusinessLevel) {
    this.businessLevel = businessLevel

    image_view.setImageUrl(businessLevel.cardImage)
    text_view_name.text = businessLevel.businessTypeName + """   """ + businessLevel.businessLevelName
    text_view_desc.text = businessLevel.description
  }

  override fun onClick(v: View?) {
    clickListener(businessLevel)
  }
}